//退出登录
$(".out-login").click(function () {
     $.ajax({
         type:"get",
         url: "outLogin",
         success: function (result) {
             console.log("result:" + result);

                 location.href = "http://localhost:8080/index.jsp";

         }

     })
})


getCustImg()
//得到照片url
function getCustImg() {
    $.ajax({
        type: "get",
        // contentType: "application/json",
        // data:
        //     `{"number":${number}}`
        // `{"numberPwd":${numberPwd}}`
        // ,
        // dataType: "json",
        url: "getCustImg",
        success: function (result) {
            // console.log("result:" + result);
            if (result===null||result===""){

            }else {
                var custImgUrl = document.getElementById("image");
                custImgUrl.src= result
                // console.log(custImgUrl)
            }

            // var pwd = result.data;
            // if (result.code === 200){
            //     if (pwd===numberPwd){
            //         location.href = "http://localhost:8080/index.jsp";
            //     }else {
            //         alert("账号或密码错误");
            //     }
            // }
            // else
            //     alert(result.data);
        }
    })
}
//用户头像

//前端js
document.querySelector(".title-primitive").mouseover=function () {
    document.querySelector(".title-img").style.transform=scale(1.1);
}


var day;
function getDay(){
    var liveDate = $("#test6").val()
    var dateStrArr = liveDate.split("-", 6)
    var startStr = dateStrArr[0]+"-"+dateStrArr[1]+"-"+dateStrArr[2]
    var endStr = dateStrArr[3]+"-"+dateStrArr[4]+"-"+dateStrArr[5]
    console.log(startStr)
    console.log(endStr)
    var startDate= new Date(Date.parse(startStr.replace(/-/g,   "/")));
    var endDate= new Date(Date.parse(endStr.replace(/-/g,   "/")));
    var time1 = startDate.getTime()
    var time2 = endDate.getTime()
    var total = (time2 - time1)/1000;
    day = parseInt(total / (24*60*60));//计算整数天数

}
//日历选择器
var nowTime=new Date();
layui.use('laydate', function() {
    var laydate = layui.laydate;
    laydate.render({
        elem: '#test6'
        , range: true
        ,min:'nowTime'
    });
})


$(".searchbox-button").click(function () {
    var placeName = $("#destination").val()
    getDay()
    console.log(day)
    if (placeName==null||placeName===""){
        alert("请填写目的地")
    }else {
        findByDestination()
    }
})

function findByDestination() {
    var hotelCity = $("#destination").val()
    console.log(hotelCity)
    $.ajax({
        type:"post",
        contentType: "application/json",
        data:
            hotelCity
        // `{"numberPwd":${numberPwd}}`
        ,
        // dataType: "json",
        url: "getByCity",
        success: function (result) {
            console.log(result)
            if (result===null||result===""){
                alert("请先登录")
            }else {
                location.href = "http://localhost:8080/hotel/hotel_list.jsp";
                // var hotels = result.data
                // // console.log(hotels)
                // for (var i=0;i<hotels.length;i++){
                //     // console.log(hotels[i].hotelId)
                // }
            }
        }
    })
}


$(".custCenter").click(function () {
    $.ajax({
        type:"get",
        url: "jump",
        success: function (result) {
            location.href="http://localhost:8080/customer/personal.jsp"
        }
    })
})




